package yichangchuli;

import java.util.Scanner;

public class price05 {
    public static void main(String[] args) {
        Student student = new Student();
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入姓名");
        String line = sc.nextLine();
        student.setName(line);

        while (true) {
            System.out.println("请输入年龄");
            String age = sc.nextLine();

            try {
                int age1 = Integer.parseInt(age);
                student.setAge(age1);
                break;
            } catch (NumberFormatException e) {//格式转换异常
                System.out.println("输入整数");
                continue;
            } catch (AgeOutofBoundException e) {
                System.out.println("重新输入一个范围内的值");
                continue;
            }

//            if (age1 >= 18 && age1 <= 25) {
//            student.setAge(age1);
//            break;
//        } else {
//            System.out.println("重新输入");
//            continue;
//        }
        }
        System.out.println(student);
    }
}